<?php

/**
 * This is the model class for table "{{bukutamu_artikel}}".
 *
 * The followings are the available columns in table '{{bukutamu_artikel}}':
 * @property string $id
 * @property string $nama
 * @property string $email
 * @property string $alamat
 * @property string $komentar
 * @property string $jawaban
 * @property string $tgl_create
 * @property string $status
 * @property string $ip_guest
 * @property string $id_artikel
 *
 * The followings are the available model relations:
 * @property Artikel $idArtikel
 */
class BukutamuArtikel extends CActiveRecord
{
    public $isi;
    public $verifyCode;
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BukutamuArtikel the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{bukutamu_artikel}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama, email, komentar, id_artikel', 'required'),
			array('nama, email', 'length', 'max'=>225),
			array('alamat', 'length', 'max'=>50),
			array('status', 'length', 'max'=>1),
			array('ip_guest', 'length', 'max'=>40),
			array('id_artikel', 'length', 'max'=>10),
			array('jawaban, tgl_create', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, nama, email, alamat, komentar, jawaban, tgl_create, status, ip_guest, id_artikel,isi', 'safe', 'on'=>'search'),
            array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idArtikel' => array(self::BELONGS_TO, 'Artikel', 'id_artikel'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nama' => 'Nama',
			'email' => 'Email',
			'alamat' => 'Situs',
			'komentar' => 'Komentar',
			'jawaban' => 'Jawaban',
			'tgl_create' => 'Tgl Create',
			'status' => 'Status',
			'ip_guest' => 'Ip Guest',
			'id_artikel' => 'Id Artikel',
            'isi' => 'Isi Artikel',
             'verifyCode'=>'Verification Code',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('nama',$this->nama,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('alamat',$this->alamat,true);
		$criteria->compare('komentar',$this->komentar,true);
		$criteria->compare('jawaban',$this->jawaban,true);
		$criteria->compare('tgl_create',$this->tgl_create,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('ip_guest',$this->ip_guest,true);
		$criteria->compare('id_artikel',$this->id_artikel,true);

        $criteria->with = array('idArtikel');
        $criteria->compare('idArtikel.isi', $this->isi, true);
        
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}